<%@ include file="/taglibs.jsp"%>
<jsp:directive.page import="java.util.Random"/>
<jsp:directive.page import="java.util.Date"/>
<%if(session.getAttribute("randFormID") == null){
	Random gen = new Random(new Date().getTime());
	session.setAttribute("randFormID", gen.nextInt() + "");
}%>

<title>Winter War Administration - Slots</title>

<button onclick="location.href='slot.do?method=edit&amp;conID=${conID}'">Add Slot</button>

<table class="list">
	<thead>
		<tr>
			<th><bean:message key="slot.slotName"/></th>
			<th><bean:message key="slot.startDate"/></th>
			<th><bean:message key="slot.endDate"/></th>
			<th><bean:message key="slot.tableAllocation"/></th>
			<th><bean:message key="slot.eventCount"/></th>
			<th><bean:message key="slot.isLocked"/></th>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="slot" items="${slots}" varStatus="status">
			<c:choose>
				<c:when test="${status.count % 2 == 0}"><tr class="even"></c:when>
				<c:otherwise><tr class="odd"></c:otherwise>
			</c:choose>
				<td><a href="slot.do?method=edit&amp;slotID=${slot.slotID}&amp;conID=${slot.conID }">${slot.slotName}</a></td>
				<td>${slot.startDateDate}<br/> ${slot.startDateHour}-${slot.startDateAMPM }-</td>
				<td>${slot.endDateDate}<br/> ${slot.endDateHour}-${slot.endDateAMPM }-</td>
				<td>${slot.usedTables } / ${slot.totalTables }</td>
				<td>${slot.eventCount }</td>
				<td>
					<c:choose>
						<c:when test="${slot.isLocked }">Locked</c:when>
					</c:choose>
				</td>
			</tr>
		</c:forEach>
		<tr>
			<html:form action="/wwadmin/slot" focus="slot.slotName">
				<input type="hidden" name="method" value="save"/>
				<input type="hidden" name="formID" value="<%=session.getAttribute("randFormID") %>"/>
				<input type="hidden" name="conID" value="${conID}"/>
				<td><html:text property="slot.slotName" value=""/></td>
				<td>
					<html:text property="slot.startDateDate" value=""/>
					<html:select property="slot.startDateHour" value="01">
						<html:option value="01">1</html:option>
						<html:option value="02">2</html:option>
						<html:option value="03">3</html:option>
						<html:option value="04">4</html:option>
						<html:option value="05">5</html:option>
						<html:option value="06">6</html:option>
						<html:option value="07">7</html:option>
						<html:option value="08">8</html:option>
						<html:option value="09">9</html:option>
						<html:option value="10">10</html:option>
						<html:option value="11">11</html:option>
						<html:option value="12">12</html:option>
					</html:select>
					<html:select property="slot.startDateAMPM" value="AM">
						<html:option value="AM">AM</html:option>
						<html:option value="PM">PM</html:option>
					</html:select>
				</td>
				<td>
					<html:text property="slot.endDateDate" value=""/>
					<html:select property="slot.endDateHour" value="01">
						<html:option value="01">1</html:option>
						<html:option value="02">2</html:option>
						<html:option value="03">3</html:option>
						<html:option value="04">4</html:option>
						<html:option value="05">5</html:option>
						<html:option value="06">6</html:option>
						<html:option value="07">7</html:option>
						<html:option value="08">8</html:option>
						<html:option value="09">9</html:option>
						<html:option value="10">10</html:option>
						<html:option value="11">11</html:option>
						<html:option value="12">12</html:option>
					</html:select>
					<html:select property="slot.endDateAMPM" value="AM">
						<html:option value="AM">AM</html:option>
						<html:option value="PM">PM</html:option>
					</html:select>
				</td>
				<td><html:submit>Save</html:submit></td>
			</html:form>
		</tr>
	</tbody>
</table>